{ 
Indicator:  _Avg$Traded.RS       (Average Dollars Traded)    

Purpose:    Total number of dollars traded on each bar (Closing Price X Bar Volume)

            if Daily, Weekly or Monthly Chart, average dollars traded is in Millions (x $1,000,000)
            if Intraday (minutes) Charts, average dollars traded is in Thousands (x $1,000)

            Does not work with tick charts.

Note:       Leave formatting option "Update value intrabar (tick by tick)" unchecked (disabled).

Author:     MarkSanDiego

Updated:    06/09/07     original version
            01/07/08     added ratio of average dollars traded
            06/27/08     improved display formatting
            01/31/10     posted to forum
            01/29/11     version 9.0 update
}


Inputs:        
    Length1(10),                 { number of bars in short moving average of dollars traded daily }
    Length2(50),                 { number of bars in long moving average of dollars traded daily }
    Min$(0.5),                   { liquidity minimum in average dollars traded per day (Millions) }
    Color1(white),               { color of average dollars traded in Length1 bars }
    Color2(yellow),              { color of average dollars traded in Length2 bars }
    Low$Color(Red),              { background color highlighting dollar averages below Min$ }
    RatioAlert(2),
    RatioAlertColor(yellow),
    LengthColor(cyan);

vars:
    adt1(0), 
    adt2(0),
    Ratio(0);

    Plot1(Min$,"Min $ (Mil)", yellow);
    SetPlotBGColor(1, blue);
    
    Plot2(Length1, "Len 1", LengthColor);
            
    if length1 > 0 then begin
        adt1 = _AvgDollarsTraded(AvgPrice, Length1);   
        Plot3(adt1, "Avg 1 ($Mil)", Color1);            { if intraday, should say ($K, not $Mil) }
        if adt1 <= Min$ then begin
            SetPlotColor(3, Black);
            SetPlotBGColor(3, Low$Color);
        end;
    end;
        
    Plot4(Length2, "Len 2", LengthColor);
            
    if length2 > 0 then begin
        adt2 = _AvgDollarsTraded(AvgPrice, Length2);
        Plot5(adt2, "Avg 2 ($Mil)");                    { if intraday, should say ($K, not $Mil) }
        if adt2 <= Min$ then begin
            SetPlotColor(5, Black);
            SetPlotBGColor(5, Low$Color);
        end else begin
            SetPlotColor(5, Color2);
            SetPlotBGColor(5, Black);
        end;
    end;

    if adt2 <> 0 then begin    
        Ratio = adt1/adt2;
        Plot6(Ratio,"$ Ratio", DarkGray);
        if Ratio >= RatioAlert then begin
            SetPlotColor(6, Black);
            SetPlotBGColor(6, RatioAlertColor);
        end;
    end;    